package middlewareorid.engine;

import superwaba.ext.xplat.io.http.URI;
import waba.sys.Vm;

public abstract class BlogsoridEngine extends BlogsEngine {
	
	
	protected BlogsoridEngine(String url) {
		super(url);
	}

	public static String getBlogListURL(String urlBase) {
		String result = urlBase + "/djokdja.php?djokdjaid=danarwidyantoro&djokdjaAction=querycategory";
		return result;
	}
	
	public static int addBlogs(String title, String category, String data, String user, String password) {
		int result = -1;
		String url = "http://blogs.or.id/djokdja.php?";
		String qs = "djokdjaid=" + URI.encode(user) + "&";
		qs = qs + "djokdjaAction=addblogs" + "&";
		qs = qs + "user=" + URI.encode(user) + "&";
		qs = qs + "password=" + URI.encode(password) + "&";
		qs = qs + "category=" + URI.encode(category) + "&"; 
		qs = qs + "body=" + URI.encode(data) + "&";
		qs = qs + "title=" + URI.encode(title);
		qs = url + qs;
		Vm.debug("QS : " + qs);
		HTMLConnect hc = new HTMLConnect();
		hc.setURL(qs);
		String respon = hc.getURLData();
		if (respon.indexOf("[RSP]OK[/RSP]") > 0) result = 1;
		Vm.debug("RS : " + respon.trim());
		return result;
	}
}
